import java.util.ArrayList;
//The purpose of using an ArrayList is to store the DVD instances in the Register.

public class Register
{
    private ArrayList<DVD> collection;
    //Our register can be presented as a collection of DVDs.
    
    private static Register myRegister;
   
    /** CONSTRUCTOR */
    public Register()
    {
        collection = new ArrayList<DVD>();
    }
    
    /** ACCESSORS */
    public static Register get_register()
    {
        if(myRegister == null)
        {
            myRegister = new Register();
        }
        return myRegister;
    }
    
    public ArrayList<DVD> get_DVD()
    //Shows our DVD collection.
    {
        return collection;
    }
    public DVD find_DVD(String dvd_id)
    //Finds a particular DVD in our collection.
    {
        for(int index = 0 ; index < collection.size(); index++)
        {
            if(collection.get(index).getId().equals(dvd_id))
            {
                return collection.get(index);
            }
        }
        return null;
    }
    
    /** MUTATORS */
        public void add_DVD(String dvd_id, String title, String artist, String publicationDate)
    //Add a new DVD to our collection.
    {
        collection.add(new DVD(dvd_id, title, artist, publicationDate));
    }
    public void delete_DVD(String dvd_id)
    //Delete a DVD from our collection.
    {
        int index = collection.indexOf(find_DVD(dvd_id));
        collection.remove(index);
    }
    public void update_DVD(DVD myDVD, String dvd_id, String title, String artist, String publicationDate)
    //Updates details of a DVD in our collection.
    {
        myDVD.setId(dvd_id);
        myDVD.setTitle(title);
        myDVD.setArtist(artist);
        myDVD.setPublicationDate(publicationDate);
    }
}